package com.xu.mb3.mbtools;

import org.apache.ibatis.reflection.property.PropertyTokenizer;

/**
 * @author xuguan
 * @since 2024/11/15
 */
public class PropertyTokenizerSample {
    private static PropertyTokenizer prop = new PropertyTokenizer("userInfo.addresses[0].province");

    public static void propertyTokenizerSample() {
        while (prop.hasNext()) {
            System.out.println("---------------------begin---------------------------");
            System.out.println("prop.getName() = " + prop.getName());
            System.out.println("prop.getChildren() = " + prop.getChildren());
            System.out.println("prop.getIndex() = " + prop.getIndex());
            System.out.println("prop.getIndexedName() = " + prop.getIndexedName());
            System.out.println("----------------------end--------------------------");

            prop = prop.next();
        }
    }

    public static void propertyTokenizerRecursionSample(PropertyTokenizer prop) {

        if (prop.hasNext()) {
            System.out.println("---------------------begin---------------------------");
            System.out.println("prop.getName() = " + prop.getName());
            System.out.println("prop.getChildren() = " + prop.getChildren());
            System.out.println("prop.getIndex() = " + prop.getIndex());
            System.out.println("prop.getIndexedName() = " + prop.getIndexedName());
            System.out.println("----------------------end--------------------------");

            propertyTokenizerRecursionSample(prop.next());
        }
    }

    public static void main(String[] args) {
        propertyTokenizerSample();

        // propertyTokenizerRecursionSample(prop);

    }
}
